<?php 
/**
* @author Oliver Leisalu
* Helper class that helps to debug DomAr
*/
class DomEventTree {

	public static $events = array();
	
	public static $level = 0;

	public static function open( $description ) {
		self::$events[] = array('description'=>$description,'level' => self::$level);
		self::$level++;
		return self::$level;
	}
	
	public static function close( $description ) {
		self::$events[] = array('description'=>$description,'level' => self::$level-1);
		self::$level--;
	}
	
	public function entry( $description, $level = NULL ) {
		self::$events[] = array('description'=>$description,'level' => $level ? $level : self::$level-1 );
	}
	
	public static function trace() {
		$list = '';
		foreach( self::$events as $event ) {
			for( $i=0; $i<$event['level']; $i++)
				$list .= '&nbsp;&nbsp;&nbsp;&nbsp;';
			$list .= $event['description'].'<br />';
		}
		
		return $list;
	}
	
	
}

?>